package com.yj.springbootstudy;

import javax.xml.crypto.Data;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;

public class MultiFieldSum {
//    public static void main(String[] args) {
//        User u1 = new User("lrj", "11", 10, 4);
//        User u2 = new User("ldh", "12", 20, 5);
//        User u3 = new User("lrj", "13", 30, 6);
//        User u4 = new User("ldh", "14", 40, 7);
//        User u5 = new User("ldh", "10", 10, 2);
//        List<User> l1 = new ArrayList<User>() {{
//            add(u1);
//            add(u2);
//            add(u3);
//            add(u4);
//            add(u5);
//        }};
//
//
//        Map<String, long[]> collect = l1.stream().collect(Collectors.toMap(k -> k.getName(), v -> new long[]{v.getMoney(), v.getPee()}, (x, y) -> {
//            x[0] = x[0] + y[0];
//            x[1] = x[1] + y[1];
//            return x;
//        }));
//
//        for (String key : collect.keySet()) {
//            System.out.println(key);
//        }
//
//        System.out.println("===========");
//        System.out.println(collect.get("ldh")[0]);
//        System.out.println(collect.get("ldh")[1]);
//
//
//    }

    public static void main(String[] args) throws ParseException {
        String dateStr = "2021-06-30 00:00:00";

        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Date parse = format.parse(dateStr);
        System.out.println(parse.getTime());

        Date date = new Date();
        String format1 = format.format(new Date(Long.valueOf(1609430400)));
        String[] s = format1.split(" ");
        String str = s[0];
        System.out.println(format1);
        System.out.println(str);


        ArrayList<Integer> list = new ArrayList<>();
        list.add(1);
        list.add(2);
        list.add(3);
        Integer [] a = new Integer[list.size()];
        list.toArray(a);
        System.out.println(Arrays.toString(a));

    }
}


class User {
    private String name;
    private String pass;
    private long money;
    private long pee;

    public User(String name, String pass, long money, long pee) {
        this.name = name;
        this.pass = pass;
        this.money = money;
        this.pee = pee;
    }

    public String getName() {
        return name;
    }

    public long getMoney() {
        return money;
    }

    public long getPee() {
        return pee;
    }


    @Override
    public String toString() {
        return "User{" +
                "name='" + name + '\'' +
                ", pass='" + pass + '\'' +
                ", money=" + money +
                ", pee=" + pee +
                '}';
    }
}